package com.huwaiwai.ratelimiter;

import com.google.common.util.concurrent.RateLimiter;

/**
 * @author 歪大哥😁
 * @date 2020-02-25.
 */
public class RateLimiterTesdt {

    public static void main(String[] args) throws InterruptedException {
        RateLimiter rateLimiter = RateLimiter.create(5);
        Thread.sleep(1000L);
        for (int i = 0; i < 10; i++) {
            System.out.println(rateLimiter.getRate());
            boolean b = rateLimiter.tryAcquire();
            System.out.println("[" + i + "] " + b);
        }
    }
}
